<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Api\Dream\Activity\About\SphereController;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
//        //双色球每周2,4,7 开奖 , 第2天中,10，12点进行更新
//        $schedule->call(function () {
////            $data = DB::table('dream_activity_sphere_contents')->where('status',1)->first();
//            $class = new SphereController;
//            $data = $class->prizeEvent();
//
//            Log::info('this is update prize code'.$data);
//        })->cron('0 12,15 * * 1,3,5');//每周1,3,5的12点
//

        //更新期号状态，实时更新（每分钟刷新一次）
        $schedule->call(function () {
            //获取当点
//            $data = DB::table('dream_activity_sphere_contents')->where('status',1)->first();
            $class = new SphereController;
            $data = $class->prizeEvent();

            Log::info('this is update prize code'.$data);
        })->everyMinute();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
